package models

import (
	"time"

	"go.mongodb.org/mongo-driver/bson/primitive"
)

type User struct {
	ID        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	Username  string             `bson:"username" json:"username"`
	Nickname  string             `bson:"nickname" json:"nickname"`
	Password  string             `bson:"password" json:"-"` // json:"-" 确保密码不会在JSON响应中返回
	Theme     string             `bson:"theme,omitempty" json:"theme"`
	CreatedAt time.Time          `bson:"created_at" json:"createdAt"`
	UpdatedAt time.Time          `bson:"updated_at" json:"updatedAt"`
}

type RegisterRequest struct {
	Username string `json:"username" binding:"required,min=3,max=32"`
	Nickname string `json:"nickname" binding:"required,min=2,max=32"`
	Password string `json:"password" binding:"required,min=6,max=32"`
}

type LoginRequest struct {
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
}

type LoginResponse struct {
	Token    string `json:"token"`
	Username string `json:"username"`
	Nickname string `json:"nickname"`
}

type UpdateProfileRequest struct {
	Nickname    string `json:"nickname" binding:"required,min=2,max=32"`
	OldPassword string `json:"oldPassword,omitempty"`
	NewPassword string `json:"newPassword,omitempty"`
	Theme       string `json:"theme,omitempty"`
}
